//
//  PreferentialRightTableViewCell.m
//  Project_A Gary
//
//  Created by leilei on 16/4/1.
//  Copyright © 2016年 www.lei.com. All rights reserved.
//

#import "PreferentialRightTableViewCell.h"

// 宏定义
#define CONTENTVIEW_WIDTH self.contentView.frame.size.width;
#define CONTENTVIEW_HEIGHT self.contentView.frame.size.height;


@implementation PreferentialRightTableViewCell

-(void)dealloc{
    [_backView release];
    [_title release];
    [_priceTitle release];
    [_maxDiscount release];
    [_serialGroupNamesTitle release];
    [_serialGroupNames release];
    [_endTime release];
    [_orderCount release];
    [_photo release];
    [super dealloc];
}

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        // 背景
        self.backView = [[UIView alloc] init];
        self.backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_backView];
        [_backView release];
        

        // 标题
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:_title];
        [_title release];
        
//        价格标签
        self.priceTitle = [[UILabel alloc] init];
        self.priceTitle.text = @"最高优惠(万元):";
        self.priceTitle.textColor = [UIColor redColor];
        self.priceTitle.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_priceTitle];
        [_priceTitle release];
        
//        优惠价格
        self.maxDiscount = [[UILabel alloc] init];
        self.maxDiscount.font = [UIFont systemFontOfSize:13];
        self.maxDiscount.textColor = [UIColor redColor];
        self.maxDiscount.textAlignment = NSTextAlignmentNatural;
        [self.contentView addSubview:_maxDiscount];
        [_maxDiscount release];
        
//        适用标签
        self.serialGroupNamesTitle = [[UILabel alloc] init];
        self.serialGroupNamesTitle.text = @"适用车系:";
        self.serialGroupNamesTitle.textColor = [UIColor grayColor];
        self.serialGroupNamesTitle.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_serialGroupNamesTitle];
        [_serialGroupNamesTitle release];
        
//        适用车系的内容
        self.serialGroupNames = [[UILabel alloc] init];
        self.serialGroupNames.font = [UIFont systemFontOfSize:13];
        self.serialGroupNames.textColor = [UIColor grayColor];
        self.serialGroupNames.textAlignment = NSTextAlignmentNatural;
        [self.contentView addSubview:_serialGroupNames];
        [_serialGroupNames release];
        
//        报名截止时间
        self.endTime = [[UILabel alloc] init];
        self.endTime.textColor = [UIColor grayColor];
        self.endTime.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_endTime];
        [_endTime release];
        
//        报名人数
        self.orderCount = [[UILabel alloc] init];
        self.orderCount.font = [UIFont systemFontOfSize:13];
        self.orderCount.textColor = [UIColor grayColor];
        self.orderCount.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_orderCount];
        [_orderCount release];
        
//        图片
        self.photo = [[UIImageView alloc] init];
        [self.contentView addSubview:_photo];
        [_photo release];
    }
    return self;
}


#pragma mark - 布局位置
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 5, BOUNDS_WIDTH, self.contentView.frame.size.height - 10);
    
    self.title.frame = CGRectMake(10, 10, BOUNDS_WIDTH - 20, 40);
    
    
    self.photo.frame = CGRectMake(10, self.title.frame.origin.y + 40, BOUNDS_WIDTH / 2 - 70, self.contentView.frame.size.height - 65);
    
    self.priceTitle.frame = CGRectMake(self.photo.frame.origin.x + self.photo.frame.size.width +10, self.photo.frame.origin.y +10, BOUNDS_WIDTH / 4, 20);
    
    self.maxDiscount.frame =CGRectMake(self.priceTitle.frame.origin.x + self.priceTitle.frame.size.width, self.priceTitle.frame.origin.y, BOUNDS_WIDTH / 5, 20);
    
    self.serialGroupNamesTitle.frame = CGRectMake(self.priceTitle.frame.origin.x, self.priceTitle.frame.origin.y + self.priceTitle.frame.size.height + 5, BOUNDS_WIDTH / 5 - 20, 20);
    
    self.serialGroupNames.frame = CGRectMake(self.serialGroupNamesTitle.frame.origin.x + self.serialGroupNamesTitle.frame.size.width, self.serialGroupNamesTitle.frame.origin.y, BOUNDS_WIDTH / 5, 20);
    
    self.endTime.frame = CGRectMake(self.serialGroupNamesTitle.frame.origin.x, self.photo.frame.origin.y + self.photo.frame.size.height - 20, BOUNDS_WIDTH / 2 - 60, 20);
    
    
    self.orderCount.frame = CGRectMake(BOUNDS_WIDTH - 110, self.endTime.frame.origin.y, 100, 20);
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
